Conditions | 5 |
Paths | 10 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | function instr_tree_toggle(event) { |
||
2 | event = event || window.event; |
||
3 | var clickedElem = event.target || event.srcElement; |
||
4 | |||
5 | // Если кликнули по +/- |
||
6 | if (instr_hasClass(clickedElem, 'InstrTreeExpand')) { |
||
7 | // Node, на который кликнули |
||
8 | var node = clickedElem.parentNode; |
||
9 | // Если кликнули по "Пустой странице" |
||
10 | } else if (instr_hasClass(clickedElem, 'InstrTreeEmptyPage')) { |
||
11 | // InstrTreeContent |
||
12 | var node = clickedElem.parentNode; |
||
|
|||
13 | // Node |
||
14 | node = node.parentNode; |
||
15 | // Если кликнули не в том месте |
||
16 | } else { |
||
17 | // Прерываем |
||
18 | return |
||
19 | } |
||
20 | |||
21 | // Если у Node есть потомки |
||
22 | if (instr_hasClass(node, 'InstrTreeExpandLeaf')) { |
||
23 | return // клик на листе |
||
24 | } |
||
25 | |||
26 | // определить новый класс для узла |
||
27 | var newClass = instr_hasClass(node, 'InstrTreeExpandOpen') ? 'InstrTreeExpandClosed' : 'InstrTreeExpandOpen'; |
||
28 | // заменить текущий класс на newClass |
||
29 | // регексп находит отдельно стоящий open|close и меняет на newClass |
||
30 | var re = /(^|\s)(InstrTreeExpandOpen|InstrTreeExpandClosed)(\s|$)/; |
||
31 | node.className = node.className.replace(re, '$1' + newClass + '$3') |
||
32 | } |
||
33 | |||
37 |
This check looks for variables that are declared in multiple lines. There may be several reasons for this.
In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.
If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.